
#include "wxscene.h"
#include "wxSceneCanvasBase.h"
#include "wxSceneDocument.h"
#include "wxSceneTool.h"

BEGIN_EVENT_TABLE(wxSceneCanvasBase,wxGLCanvas)
EVT_KEY_DOWN(wxSceneCanvasBase::OnKeyDown)
EVT_KEY_UP(wxSceneCanvasBase::OnKeyUp)
EVT_MOTION(wxSceneCanvasBase::OnMouseMove)
EVT_LEFT_DOWN(wxSceneCanvasBase::OnMouseDown)
EVT_LEFT_UP(wxSceneCanvasBase::OnMouseUp)
EVT_MOUSE_EVENTS(wxSceneCanvasBase::OnMouse)
EVT_MOUSE_CAPTURE_LOST(wxSceneCanvasBase::OnMouseCaptureLost)
EVT_SIZE(wxSceneCanvasBase::OnSize)
EVT_PAINT(wxSceneCanvasBase::wxPaint)
END_EVENT_TABLE()
wxSceneCanvasBase::wxSceneCanvasBase(wxWindow* parent,
                         wxWindowID id,
                         const wxPoint &pos,
                         const wxSize &size,
                         const wxString &name,
                         long style,
                         int *attributes
                         )
:wxGLCanvas(parent,id,pos,size,style,name,attributes)
,pCurTool(NULL),pDocument(NULL)
{
 
}

wxSceneCanvasBase::~wxSceneCanvasBase(void)
{
}
void wxSceneCanvasBase::wxPaint(wxPaintEvent& e)
{
    OnPaint(e);
}
void wxSceneCanvasBase::OnMouse(wxMouseEvent &e)
{
	if(pCurTool!=NULL)
		pCurTool->OnMouse(e);
}
void wxSceneCanvasBase::OnMouseDown(wxMouseEvent &e)
{
 if(pCurTool!=NULL)
     pCurTool->OnMouseDown(e);
}
void wxSceneCanvasBase::OnMouseMove(wxMouseEvent &e)
{
 if(pCurTool!=NULL)
     pCurTool->OnMouseMove(e);

}
void wxSceneCanvasBase::OnMouseUp(wxMouseEvent &e)
{
  if(pCurTool!=NULL)
      pCurTool->OnMouseUp(e);
}
void wxSceneCanvasBase::OnMouseWheel(wxMouseEvent &e)
{
  if(pCurTool!=NULL)
      pCurTool->OnMouseWheel(e);
}
void wxSceneCanvasBase::OnKeyDown(wxKeyEvent &e)
{
  if(pCurTool!=NULL)
      pCurTool->OnKeyDown(e);
}
void wxSceneCanvasBase::OnKeyUp(wxKeyEvent &e)
{
  if(pCurTool!=NULL)
      pCurTool->OnKeyUp(e);
}
void wxSceneCanvasBase::OnSize(wxSizeEvent &e)
{
    wxGLCanvas::OnSize (e);
    wxGLCanvas::Refresh();
}
void wxSceneCanvasBase::OnPaint(wxPaintEvent& e)
{
  
}


wxSceneDocument* wxSceneCanvasBase::GetDocument() const
{
    return pDocument;
}
void wxSceneCanvasBase::OnMouseCaptureLost(wxMouseCaptureLostEvent& evt)
{
}
wxSceneTool* wxSceneCanvasBase::GetCurrentTool()const
{
	return this->pCurTool;
}
void wxSceneCanvasBase::SetCurrentTool(wxSceneTool* pNewTool)
{
	this->pCurTool=pNewTool;
}
